package com.core.sdk.ui.viewpager;

import android.support.v4.app.FragmentManager;
import android.view.ViewGroup;

import com.core.sdk.ui.adapter.BaseTabStatePagerAdapter;

public abstract class JazzyViewPagerStateAdapter extends BaseTabStatePagerAdapter {
	
	JazzyViewPager viewPager;
	public JazzyViewPagerStateAdapter(FragmentManager fm,JazzyViewPager vp) {
		super(fm);
		this.viewPager = vp;
	}

	@Override
	public void destroyItem(ViewGroup container, int position, Object object) {
		super.destroyItem(container, position, object);
		container.removeView(viewPager.findViewFromObject(position));
	}

	@Override
	public Object instantiateItem(ViewGroup container, int position) {
		Object obj = super.instantiateItem(container, position);
		viewPager.setObjectForPosition(obj, position);
		return obj;
	}
	
}
